<?php
    header('Content-type:text/json');
    require "../connection.php";
    $user_id = $_POST['user_id'];
    $sql = "select id,pay_price from orders where user_id = '$user_id' and is_pay=1 and is_ship=0 and status=1";
    $res = $conn->doSql($sql);
    $arr = array();
    $len= count($res);

    for($i=0;$i<$len;$i++){
       $order_id =  $res[$i]['id'];
       $pay_price = $res[$i]['pay_price'];
       $innersql = "select goods_id,goods_num,goods_price from order_goods where order_id = '$order_id' ";
       $order_goods_res = $conn->doSql($innersql);
        $innerarr = array();
       for($j=0,$len2=count($order_goods_res);$j<$len2;$j++){
            $goods_id = $order_goods_res[$j]['goods_id'];
            $goods_num = $order_goods_res[$j]['goods_num'];
            $goods_price = $order_goods_res[$j]['goods_price'];
            $goods_sql = "select goods_name,goods_bill from goods where id='$goods_id'";
            $goods_res = $conn->doSql($goods_sql);
            $goods_name = $goods_res[0]['goods_name'];
            $goods_bill = $goods_res[0]['goods_bill'];
            array_push($innerarr,array("goods_name"=>$goods_name,"goods_bill"=>$goods_bill,"goods_id"=>$goods_id,"goods_num"=>$goods_num,"goods_price"=>$goods_price));
        }
       array_push($arr,array("0"=>$innerarr,"1"=>array("order_id"=>$order_id,"info"=>"待卖家发货")));
    }

    echo json_encode($arr);
?>
